package com.example.musicplayer.playtask;

import android.media.MediaPlayer;
import android.os.AsyncTask;

import com.thundersoft.musicplayer.listener.MusicPlayListener;

/**
 * @Author: liuzh0705
 * @Date:2021-07-30 下午7:10
 * @Description: 异步播放音乐
 */
public class MusicPlayTask extends AsyncTask<String, Integer, Integer> {

    private static final int MUSIC_ON_START_MUSIC = 0; // 开始播放音乐

    private static final int MUSIC_ON_STOP_MUSIC = 1; // 暂停播放音乐

    private static final int MUSIC_ON_UP_MUSIC = 2; // 上一曲

    private static final int MUSIC_ON_NEXT_MUSIC = 3; // 下一曲

    private MusicPlayListener musicPlayListener;

    private boolean isPlaying = false;

    private boolean isStopping = false;

    private int lastProgress;

    private MediaPlayer mediaPlayer = new MediaPlayer();

    public MusicPlayTask(MusicPlayListener musicPlayListener) {
        this.musicPlayListener = musicPlayListener;
    }

    /**
     * 后台播放/暂停的任务
     * @param strings
     * @return
     */
    @Override
    protected Integer doInBackground(String... strings) {

        if (mediaPlayer.isPlaying()) {
            mediaPlayer.start();
        }


        return null;
    }

    @Override
    protected void onProgressUpdate(Integer... values) {
        super.onProgressUpdate(values);
    }

    @Override
    protected void onPostExecute(Integer integer) {
        super.onPostExecute(integer);
    }
}
